package com.at.bigdata.spark.core.rdd.builder

import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @author cdhuangchao3
 * @date 2023/3/19 9:52 PM
 */
object Spark02_RDD_File_Par {

  def main(args: Array[String]): Unit = {
    // 环境准备
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)

    // 创建RDD
    // 底层用的Hadoop读取方式
    // math.min(defaultParallelism, 2)
//    val rdd = sc.textFile("datas/1.txt")
    // totalSize = 5
    // goalSize = 5 / 2 = 3 (byte)

    // 5 / 3 = 2...1 (1.1) + 1 = 3(分区)
    val rdd = sc.textFile("datas/3.txt", 2)

    rdd.saveAsTextFile("output")

    sc.stop()
  }

}
